﻿#pragma once
#include <QObject>
#include <QWebSocket>

class EchoClient : public QObject
{
  Q_OBJECT
 public:
  EchoClient(const QUrl& url, bool debug, QObject* parent = Q_NULLPTR);
  void connectToServer();
 private slots:
  void onConnected();
  void onTextMessageReceived(QString message);
  void closed();
  void onDisconnected();
  void onBinaryMessageReceived(const QByteArray& message);
  void onPong(quint64 elapsedTime, const QByteArray& payload);
  void onError(QAbstractSocket::SocketError error);

 private:
  QUrl m_url;
  bool m_debug;
  QWebSocket webSocket;
};